package com.xy.mq.monitor.service.impl;

import com.xy.mq.monitor.model.ClusterNode;
import com.xy.mq.monitor.service.INodeService;
import com.xy.mq.monitor.utils.HttpUtils;
import com.xy.utils.GsonUtils;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class NodeServiceImpl implements INodeService {

    public List<ClusterNode> nodes(String ip, String port, String username, String password) {
        String url = "http://" + ip + ":" + port + "/api/nodes";
        String data = HttpUtils.httpGet(url, username, password);
        List<ClusterNode> clusterNodes = GsonUtils.fromJsonToList(data, ClusterNode.class);
        return clusterNodes;
    }
}
